library(readxl)
mydata <- read_xlsx("./Holiday.xlsx")
mydata <- as.data.frame(mydata)
head(mydata)
## ID Budget Status
## 1 1 300 Student
## 2 2 400 Student
## 3 3 200 Student
## 4 4 100 Student
## 5 5 400 Student
## 6 6 100 Student
Description of the variables:
mydata$Status <- as.factor(mydata$Status)
library(ggplot2)
ggplot(mydata, aes(x = Status, y = Budget)) +
geom_violin(fill = "grey90", alpha = 0.6, trim = FALSE) +
geom_boxplot(width = 0.1, fill = "grey60", outlier.shape = NA) +
labs(title = "Distribution of Holiday Budget by Status",
x = "Status",
y = "Planned Holiday Budget") +
theme_bw()
library(rstatix)
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
mydata %>%
group_by(Status) %>%
get_summary_stats(Budget, type = "median_iqr")
## # A tibble: 3 × 5
## Status variable n median iqr
## <fct> <fct> <dbl> <dbl> <dbl>
## 1 Employed Budget 45 600 300
## 2 Retired Budget 18 300 200
## 3 Student Budget 30 250 200
library(rstatix)
mydata %>%
group_by(Status) %>%
shapiro_test(Budget)
## # A tibble: 3 × 4
## Status variable statistic p
## <fct> <chr> <dbl> <dbl>
## 1 Employed Budget 0.968 0.239
## 2 Retired Budget 0.900 0.0575
## 3 Student Budget 0.892 0.00527
kruskal.test(Budget ~ Status,
data = mydata)
##
## Kruskal-Wallis rank sum test
##
## data: Budget by Status
## Kruskal-Wallis chi-squared = 36.798, df = 2, p-value =
## 1.022e-08
kruskal_effsize(Budget ~ Status,
data = mydata)
## # A tibble: 1 × 5
## .y. n effsize method magnitude
## * <chr> <int> <dbl> <chr> <ord>
## 1 Budget 93 0.387 eta2[H] large
library(rstatix)
groups_nonpar <- wilcox_test(Budget ~ Status,
paired = FALSE,
p.adjust.method = "bonferroni",
data = mydata)
groups_nonpar
## # A tibble: 3 × 9
## .y. group1 group2 n1 n2 statistic p p.adj
## * <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl>
## 1 Budget Employed Retired 45 18 660. 0.0000415 1.25e-4
## 2 Budget Employed Student 45 30 1190. 0.00000000114 3.41e-9
## 3 Budget Retired Student 18 30 330 0.196 5.87e-1
## # ℹ 1 more variable: p.adj.signif <chr>